package aiku.numericalcontroloa.Controller.Products;

import aiku.numericalcontroloa.Base.Utils.Result;
import aiku.numericalcontroloa.Model.Entity.ProductPart;
import aiku.numericalcontroloa.Model.Vo.ProductPartVo;
import aiku.numericalcontroloa.Service.Impl.ProductPartServiceImpl;
import aiku.numericalcontroloa.Service.ProductPartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 马文杰
 * @version 1.0
 */
@RestController
@RequestMapping("productPart")
public class ProductPartController {
    @Autowired
    private ProductPartServiceImpl productPartService;
    /**
     * 管理员给产品添加配件
     */
    @PostMapping("addProductPart")
    public Result addProductPart(@RequestBody ProductPartVo partVo){
        Result  rest = productPartService.addProductPart(partVo);
        return rest;
    }
    /**
     * 通过id查询成品配件
     */
    @PostMapping("ProductPartId")
    public Result selectProductPartId(@RequestParam("ProductPartId") String id){
        Result  rest = productPartService.selectProductPartId(id);
        return rest;
    }

    /**
     * 根据产品id查询产品所需配件是否充足，以及百分比显示
     */
    @PostMapping("selectProductPartList")
    public Result selectProductPartList(@RequestParam("ProductPartId") String productPartId){
        Result rest = productPartService.selectProductPartList(productPartId);
        return rest;
    }


}
